

<template>
	<!-- 二次核对 -->
	<u-popup :show="visible" 
        closeable 
        @close="handleClose()"
        overlayStyle="z-index:10075;"
    >
        <view class="double-check">
            <view class="double-check-title">二次核对</view>
            <view class="double-check-form-item">
                <view class="double-check-form-item-label">护士用户名：</view>
                <view class="double-check-form-item-input">
                    <u-input v-model="doubleCheckForm.userName" type="text"
                    placeholder="请输入用户名" clearable/>
                </view>
            </view>
            <view class="double-check-form-item">
                <view class="double-check-form-item-label">护士密码：</view>
                <view class="double-check-form-item-input">
                    <u-input v-model="doubleCheckForm.password" type="password" 
                    placeholder="请输入密码" clearable/>
                </view>
            </view>
            <view class="submit-button">
                <button @click="handleSubmit()">提交结果</button>
            </view>
        </view>
    </u-popup>
</template>

<script>
import { mapState } from "vuex"
import {
	getDateTimeString,
	getAdviceType,
	getPlanStatus,
	showToast,
} from "@/static/js/common.js"

export default {
	components: {},
	props: {},
	data() {
		return {
			visible: false, //弹窗显示

			doubleCheckForm: {
				userName: null, //护士用户名
				password: null, //护士密码
				userId: null, //用户id
                userNa:null,//用户姓名
			},
		}
	},
	watch: {},
	computed: {
		...mapState(["loginUser", "area"]),
	},
	beforeDestroy() {},
	mounted() {},
	methods: {
		show(obj) {
			this.visible = true
		},
		handleClose() {
			this.visible = false
			this.doubleCheckForm = {
				userName: null, //护士用户名
				password: null, //护士密码
				userId: null, //用户id
                userNa:null,//用户姓名
			}
		},
		async handleSubmit() {
            let params = {
				yhdm: this.doubleCheckForm.userName,
				pwd: this.doubleCheckForm.password, // 输入 noPwd 时测试用 不走密码验证
				jgid: this.loginUser.JGID,
			}
			let result = await this.$commonAjaxGet("/mobile/user/checkUser", params)
			if (result.res.ReType == 0) {
				if (result.res.Data.YHID == this.loginUser.YHID) {
					showToast(-1,'请更换护士进行二次核对')
					return
				}
				this.doubleCheckForm.userId = result.res.Data.YHID;
                this.doubleCheckForm.userNa = result.res.Data.YHXM;
                this.$emit('closeAndSubmit',this.doubleCheckForm);
                this.visible = false;
			} else {
				showToast(-1,'用户验证失败')
				return
			}
			
		},
	},
}
</script>

<style lang="scss">
.double-check{
    height: 500rpx;
    position: relative;
    padding: 20rpx;
    .double-check-title{
        font-size: 34rpx;
        text-align: center;
        margin-bottom: 30rpx;
    }
    .double-check-form-item{
        display: flex;
        align-items: center;
        margin-bottom: 20rpx;
        .double-check-form-item-label{
            font-size: 32rpx;
            width: 200rpx;
        }
        .double-check-form-item-input{
            .u-input{
                background-color: #F9F9F9;
                width: 460rpx;
            }
        }
    }
    .submit-button{
        bottom: 10px;
        text-align: center;
        button{
            color: #FFFFFF;
            background-color: #4088FE;
            width: calc(100% - 20rpx);
            position: absolute;
            bottom: 0px;
            
        }
    }
}
</style>
